import Vue from 'vue'
//定义全局过滤器
//定义时间过滤器
export default Vue.filter('formatDate', function (dataStr, patten = '') { 
  var bt = new Date(dataStr);
  var y = bt.getFullYear();
  var m = (bt.getMonth() + 1).toString().padStart(2, '0');
  var d = bt.getDate().toString().padStart(2, '0');
  var hh = bt.getHours().toString().padStart(2, '0');
  var mm = bt.getMinutes().toString().padStart(2, '0');
  var ss = bt.getSeconds().toString().padStart(2, '0');
  if (patten.toLowerCase() === 'yyyy-mm-dd') {
    console.log(`${y}-${m}-${d}`)
    return `${y}-${m}-${d}`
  } else {
    console.log(`${y}-${m}-${d} ${hh}:${mm}:${ss}`)
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  }
 })
